package com.bocaizp.operation.mapper;

import com.bocaizp.pojo.DTO.UserForecastDTO;
import com.bocaizp.pojo.VO.EmployeeVO;
import com.bocaizp.pojo.entity.Employee;
import org.apache.ibatis.annotations.*;

import java.time.LocalDateTime;
import java.util.List;

/**
 * Author : huang jie
 * Date : 2024/5/7 17:54
 **/
@Mapper
public interface UserInfoMapper {

	/**
	 * 更新旧的头像信息
	 * @param path
	 * @param currentId
	 */
	@Update("update user set avatar = #{path} where id = #{currentId}")
	void updateAvatar(@Param("path") String path,@Param("currentId") Long currentId);

	/**
	 * 得到旧的头像
	 * @param id
	 * @return
	 */
	@Select("select avatar from user where id = #{id}")
	String getAvatar(Long id);

	/**
	 * 得到旧的简历
	 * @param id
	 * @return
	 */
	@Select("select user_bio from user where id = #{id}")
	String getBio(Long id);

	/**
	 * 更新简历
	 * @param path
	 * @param currentId
	 */
	@Update("update user set user_bio = #{path} where id = #{currentId}")
	void updateBio(@Param("path")String path,@Param("currentId") Long currentId);

	/**
	 * 修改密码
	 * @param password
	 * @param id
	 */
	@Update("update user set password = #{password} where id = #{id}")
	void updatePassword(@Param("password") String password,@Param("id") Long id);

	/**
	 * 存入用户
	 * @param user
	 */
	@Insert("insert into user_test (last_login_time, interview_number, login_number, create_time) VALUES " +
			"(#{lastLoginTime},#{interviewNumber},#{loginNumber},#{createTime})")
	void insert(UserForecastDTO user);

	@Select("select id from user_test")
	List<Integer> select();

	@Update("update user_test set last_login_time = #{format} where id = #{x}")
	void update(@Param("x") int x,@Param("format") LocalDateTime format);

	@Select("select emp_id, username, sex, emp_group, emp_age, phone, card_id from employee")
	List<EmployeeVO> getEmployeeInfo();

	/**
	 * 新增员工
	 *
	 * @param employee
	 * @return
	 */
	void addEmployee(Employee employee);
}
